package com.project.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.Student;
import com.project.mapper.IStudentMapper;
import com.project.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional//说明此类的方法是事务提交
public class StudentServiceImpl implements IStudentService {
    @Autowired//自动注册此mapper,先检查类型，在自动添加
    private IStudentMapper mapper;

    @Override
    public void add(Student student) {
        mapper.add(student);
    }

    @Override
    public void del(int id) {
        mapper.del(id);
    }

    @Override
    public void update(int id, String name) {
        mapper.update(id,name);
    }

    @Override
    public List<Student> findAll() {
        return mapper.findAll();
    }

    @Override
    public PageInfo<Student> cutAll(int page) {
        PageHelper.startPage(page,3);
        PageInfo<Student> pageInfo = PageInfo.of(mapper.findAll());
        return pageInfo;
    }

}
